package com.itheima.reggie.common;


/**
 * 基于ThreadLocal封装工具类，用户保存和获取当前登录用户的id
 */
public class BaseContext {


    private static final ThreadLocal<Long> threadLocal = new ThreadLocal<>();

    /**
     * 存值
     * @param id
     */
    public static void setCurrentId(Long id){
        threadLocal.set(id);
    }

    /**
     * 取值
     * @return
     */
    public static Long getCurrentId(){
        return threadLocal.get();
    }

    /**
     * 释放数据
     */
    public static void release(){
        threadLocal.remove();
    }


}
